class PictureController < ActionController::Base

  def save_base64_picture
    #directory = Date.current.strftime('%Y%m%d')
    file_name = "/pictures/#{Time.now.to_i}#{Random.rand(1000)}.jpeg"
    file_abs_path = "#{Rails.root}/public#{file_name}"

    if params[:pic].size > 300000
      render json: { msg: 'img too big' }
    else
      File.open(file_abs_path, 'wb')do|f|
        f.write(Base64.decode64(params[:pic].strip))
      end
      render json: { url: file_name }
    end
  end
end